export default {
  PromotionTemplate: {
    form: {
      fields: [
        'name',
        { property: 'extends',
          required: false
        },
        {
          property: 'phase',
          help: '内部：产品项目循环内部，针对单独产品事件<br/>外部：循环外部，针对整个订单，如总价',
          component: {
            props: ['form', 'property'],
            render(h) {
              return (
                <el-select v-model={this.form[this.property]} filterable placeholder='位置'>{
                  [
                    { label: '内部', value: false },
                    { label: '外部', value: true }
                  ]
                    .map(phase => {
                      return <el-option key={phase.value} label={phase.label} value={phase.value} />
                    })
                }</el-select>
              )
            }
          }
        },
        { property: 'enabled', default_value: true },
        { property: 'fields',
          tab: '高级',
          help: `
          <b>自定义字段</b><br/>
          按 FormAdmin Fields 形式，暂不支持JSX
        `
        },
        'description',
        { property: 'validator',
          type: 'code',
          tab: '高级',
          help: `
          <b>验证器事例</b><br/>
          <ol>
            <li>
              验证会员等级<br/>
              user.member.level.slug == 'gold'
            </li>
            <li>
              按价格比例验证<br/>
              currentPrice / currentQuantity > 100
            </li>
          </ol>
        `
        },
        { property: 'priorityCalculator',
          type: 'code',
          tab: '高级',
          help: `
          <b>数值越低，优先级越高。<br/>优先级计算器事例</b><br/>
          <ol>
            <li>
              按配置里的优先级(priority)排序<br/>
              config.priority
            </li>
            <li>
              按优惠性价比排序<br/>
              promotion.getThreshold() / promotion.getAmount()
            </li>
          </ol>
        `
        },
        { property: 'executor',
          tab: '高级',
          type: 'code',
          help: `
        <b>可供参数配置</b><br/>
        Go: 起始dummy<br/>
        Math: 数学类<br/>
        Datetime: 时间类<br/>
        ArrayCommon: 数组类<br/>
        promotion: 当前促销类<br/>
        template: 当前模板类<br/>
        status: 当前状态类<br/>
        status.getCurrentQuantity(): 当前产品数量<br/>
        status.getCurrentPrice(): 当前产品单价<br/>
        status.getPriceItem(): 当前订单产品<br/>
        status.getPrices(): 当前订单价格循环
      `
        }
      ]
    },
    list: {
      list_filter: {},
      list_display: [
        'id',
        'name',
        'category',
        'extends',
        {
          property: 'phase',
          component: {
            props: ['data'],
            render(h) {
              return (
                <el-tag>{ this.data ? '外部' : '内部' }</el-tag>
              )
            }
          }
        },
        { property: 'enabled', editable: true }
      ]
    }
  }
}
